#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int add(int x, int y)
{
	return x + y;
}
int sub(int x, int y)
{
	return x - y;
}
int mul(int x, int y)
{
	return x * y;
}
int div(int x, int y)
{
	return x / y;
}

void menu(void)
{
	printf("**********************\n");
	printf("****1.add   2.sub ****\n");
	printf("****3.mul   4.div ****\n");
	printf("*********0.exit ******\n");
	printf("**********************\n");
}

int main()
{
	int input = 0;
	int ret = 0;
	int(*pr[5])(int, int) = { 0,add,sub,mul,div };
	int x, y = 0;
	do 
	{
		menu();
		printf("请选择：>");
		scanf("%d", &input);
		if ((input >= 1) && (input <= 4))
		{
			printf("请输入操作数：>");
			scanf("%d%*c%d", &x, &y);
			ret = pr[input](x, y);
			printf("%d\n", ret);
		}
		else if (input == 0)
		{
			printf("退出！\n");
			break;
		}
		else
		{
			printf("输入错误，请重新输入:>\n");
		}
	} while (input);
	return 0;
}